cmake_minimum_required(VERSION 3.5)
project(ros_usbcapture)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

# if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#   add_compile_options(-Wall -Wextra -Wpedantic)
# endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

include_directories(include)
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

ament_auto_add_library(test_component SHARED
test/GetImageTest.cpp
src/RosUsbCapture.cpp

)
ament_auto_add_library(video_component SHARED
src/RosVideoReader.cpp

)
ament_auto_add_library(camera_component SHARED
src/RosUsbCapture.cpp
src/UsbCaptureSystem.cpp

)

target_link_libraries(camera_component gxiapi)  #大恒使用必带

add_definitions(-DUSBCAPTURE_CFG="${CMAKE_CURRENT_LIST_DIR}/config/UsbCapture.yaml")

install(TARGETS 
  camera_component
  video_component
  test_component
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin)

rclcpp_components_register_nodes(camera_component "wmj::camera_node")
rclcpp_components_register_nodes(video_component "wmj::RosVideoReader")
rclcpp_components_register_nodes(test_component "wmj::Image_get_test")

#set(node_plugins "${node_plugins}wmj::camera_node;$<TARGET_FILE:camera_component>\n")

#add_executable(camera_node src/UsbCaptureSystem.cpp src/RosUsbCapture.cpp)


install(DIRECTORY launch config
  DESTINATION share/${PROJECT_NAME})

ament_package()
